package com.yao.utils;

import com.yao.exception.custom.PathExcption;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class PathDetermine {

    public static void picPath(String path) throws PathExcption{
        List<String> list = Stream.of("JPG","JPEG","jpg","jpeg","PNG","png","webp","WEBP").collect(Collectors.toList());

        List<StringBuilder> typeList = list.stream()
                .map(StringBuilder::new) // 使用构造函数将每个字符串转换为 StringBuilder
                .collect(Collectors.toList());

        String types = typeList.stream().collect(Collectors.joining("|"));

        if(!(path.substring(path.lastIndexOf("/")+1).matches(".*(" + types + ".*)"))) throw new PathExcption("PATH_EXCPTION: 传入路径异常");
    }
}
